package com.hk.servlet;

import com.hk.model.ContactUs;
import com.hk.service.IContactUsService;
import com.hk.service.impl.ContactUsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: KangWang
 * Date: 2021/5/20 17:35
 * State：
 */
@WebServlet("/contactUs")
public class ContactUsServlet extends HttpServlet {

    IContactUsService iContactUsService = new ContactUsServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //        设置UTF-8
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        ContactUs contactUs = iContactUsService.findAllContactUs();
//        存储
        req.setAttribute("contactUs",contactUs);
//        页面转发
        req.getRequestDispatcher("/jsp/contact_us.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
